package com.xuyuan.json.jackson.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xuyuan.json.jackson.custom.MyDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/xuyuan")
@RestController
public class TestController {
    @Autowired
    ObjectMapper objectMapper;

    @PostMapping("/test")
    public String test(@RequestBody MyDto bodys) throws JsonProcessingException {
        return objectMapper.writeValueAsString(bodys);
    }
}
